app.util = app.util || {};

app.util.firstDayofMonth = new Date(new Date().getFullYear(),new Date().getMonth(),1);

app.util.getQueryStringValue = function(name)
{
    var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i"); 
    if (reg.test(location.href)) return unescape(RegExp.$2.replace(/\+/g, " ")); return "";
};

app.util.defaultLanguage = "zh-cn";

app.util.getLocale = function() {

	var locale = app.util.getQueryStringValue("lang");
	
	if(locale == null || locale.length ==0) {
		locale = app.util.defaultLanguage;
	}
	
	return locale;
};

app.util.getI18NFile = function() {
	var locale = app.util.getLocale();
	
	var i18nFile = "zh-cn.js";
	
	//in case of "en"/"cn" parms in browser
	if(locale == "en") {
		i18nFile = "en-us.js";
	} else if(locale == "cn") {
		i18nFile = "zh-cn.js"
	} else {
		i18nFile = locale + ".js";
	}
	
	//prefix
	
	i18nFile = "i18n" + "/" + i18nFile;
	
	return i18nFile;
	
};

app.util.isDevelopmentMode = function() {
	var isDevelopment = false;
	
	var deployment = app.util.getQueryStringValue("mode");
	
	if(deployment !=null && deployment == "dev") {
		isDevelopment = true;
	}
	
	return isDevelopment;
};


/*
app.util.emptyPassword = function (){
	if (!$password || $password == "null"){
		$password="";
	};
};
*/
